//
//  UIView+MCFlagAttribute.m
//  MirkoLibTest
//
//  Created by Mirko on 2017/3/21.
//  Copyright © 2017年 Mirko. All rights reserved.
//

#import "UIView+MCFlagAttribute.h"
#import <objc/runtime.h>

static const char kMCViewFlagKey;

@implementation UIView (MCFlagAttribute)

-(NSString *) mcViewFlag{
    __block NSString *value = objc_getAssociatedObject(self, &kMCViewFlagKey);
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (value == nil) {
            value = @"-1";
            [self setMcViewFlag:value];
        }
    });
    return value;
}
-(void) setMcViewFlag:(NSString *) mcViewFlag{
    objc_setAssociatedObject(self, &kMCViewFlagKey, mcViewFlag, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

@end
